Procesado de Señales e Imágenes Médicas

Ingeniería Biomédica

Ph.D. Pablo Eduardo Caicedo Rodríguez

2024-01-22

Procesamiento de imágenes

Basic Mathematic - Element-Wise Operation

Definition

Operation involving one or more images is carried out on a pixel-bypixel basis

\[ \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix} \oplus \begin{bmatrix} b_{11} & b_{12} \\ b_{21} & b_{22}\end{bmatrix} = \begin{bmatrix} a_{11}+b_{11} & a_{12}+b_{12} \\ a_{21}+b_{21} & a_{22}+b_{22}\end{bmatrix} \]

\[ \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix} \odot \begin{bmatrix} b_{11} & b_{12} \\ b_{21} & b_{22}\end{bmatrix} = \begin{bmatrix} a_{11}.b_{11} & a_{12}.b_{12} \\ a_{21}.b_{21} & a_{22}.b_{22}\end{bmatrix} \]

Basic Mathematic - Linear Operations

Definition

Given two arbitrary constants, \(\alpha_1\) and \(\alpha_2\), and two arbitrary images \(f_1\left(x,y\right)\) and \(f_2\left(x,y\right)\), \(\varkappa\) is said to be a linear operator if:

\[ \begin{equation}\begin{split} \varkappa\left[\alpha_1 f_1\left(x,y\right) + \alpha_2 f_2\left(x,y\right)\right] & = \alpha_1 \varkappa\left[ f_1\left(x,y\right)\right] + \alpha_2 \varkappa\left[f_2\left(x,y\right)\right] \\ & = \alpha_1 g_1\left(x,y\right) + \alpha_2 g_2\left(x,y\right) \end{split}\end{equation} \]

Supose \(\alpha_1 = 5\), \(\alpha_2 = 2\), \(\varkappa = max\) and consider:

\[f_1 = \begin{bmatrix}0 & -1 \\2 & 4\end{bmatrix}\], \[f_2 = \begin{bmatrix}30 & 4 \\-2 & -3\end{bmatrix}\]

Basic Mathematic - Adding

Basic Mathematic - Adding

 

x_ray_chest = cv2.imread("images/female-chest-x-ray.jpg")
plt.imshow(x_ray_chest, cmap="gray")
plt.show()
image_synt1 = 100*np.abs(np.random.normal(0, 1, x_ray_chest.shape))
plt.imshow(image_synt1)
plt.show()
final_image = np.uint8(x_ray_chest+image_synt1)
plt.imshow(final_image)
plt.show()

Basic Mathematic - Multiplying

 

x_ray_chest = cv2.imread("images/female-chest-x-ray.jpg")
mask = np.uint8(np.zeros(x_ray_chest.shape))
mask[400:700, 250:600, :]=1
plt.imshow(x_ray_chest)
plt.show()
plt.imshow(255*mask)
plt.show()
plt.imshow(np.multiply(x_ray_chest,mask))
plt.show()

Basic Mathematic - Pixel intensity

Original

Exp=1.1

Exp=1.2

Exp=0.2

Exp=0.30

Exp=0.5
x_ray_chest_gray = cv2.cvtColor(x_ray_chest, cv2.COLOR_BGR2GRAY)
plt.imshow(x_ray_chest_gray, cmap="gray")
plt.show()
plt.imshow(np.power(x_ray_chest_gray,1.1), cmap="gray")
plt.show()
plt.imshow(np.power(x_ray_chest_gray,1.2), cmap="gray")
plt.show()
plt.imshow(np.power(x_ray_chest_gray,0.2), cmap="gray")
plt.show()
plt.imshow(np.power(x_ray_chest_gray,0.3), cmap="gray")
plt.show()
plt.imshow(np.power(x_ray_chest_gray,0.5), cmap="gray")
plt.show()

Basic Mathematic - Pixel intensity

Taken from: Gonzalez, Rafael C., y Richard E. Woods. Digital Image Processing. New York, NY: Pearson, 2018.

Basic Mathematic - Pixel intensity

Taken from: Gonzalez, Rafael C., y Richard E. Woods. Digital Image Processing. New York, NY: Pearson, 2018.

Neighborhood operations

Taken from: Gonzalez, Rafael C., y Richard E. Woods. Digital Image Processing. New York, NY: Pearson, 2018.

Neighborhood Operations

For example, suppose that the specified operation is to compute the average value of the pixels in a rectangular neighborhood of size mn × centered on \(\left(x,y\right)\). The coordinates of pixels in this region are the elements of set \(S_{xy}\).

Elderly woman image

Gray-scale image
elderly = cv2.imread("./images/elderly.jpg")
plt.imshow(elderly)
elderly_gray = cv2.cvtColor(elderly, cv2.COLOR_BGR2GRAY)
plt.imshow(elderly_gray, cmap="gray")

Neighborhood operations

N = 10
kernel = np.ones((N,N),np.float32)/(N*N)
dst = cv2.filter2D(elderly_gray,-1,kernel)
plt.imshow(dst, cmap="gray")

Neighborhood operations

N=11

dst1 = cv2.medianBlur(elderly_gray, N)
plt.imshow(dst1, cmap="gray")

Neighborhood operations

Neighborhood operations

Taken from: Gonzalez, Rafael C., y Richard E. Woods. Digital Image Processing. New York, NY: Pearson, 2018.

Neighborhood operations

Taken from: http://datagenetics.com/blog/august32013/index.html

Edge dection

Edge dection

Edge dection

dst = cv2.Sobel(elderly_gray, cv2.CV_16S, 1, 0,  ksize=3, scale=1, delta=0, borderType= cv2.BORDER_DEFAULT)
dst1 = np.uint8(255*dst/np.max(dst))
plt.imshow(dst1, cmap="gray")

Histogram

elderly_hist = cv2.calcHist(elderly_gray, [0], None, [256], [0,256])
plt.plot(elderly_hist, color="gray")